package ca.etsmtl.log430.lab2;

import java.util.Observable;

import ca.etsmtl.log430.common.Displays;
import ca.etsmtl.log430.common.Menus;
import ca.etsmtl.log430.common.Project;



public class ListRolesAssignedtoProject extends Communication {

	public ListRolesAssignedtoProject(Integer registrationNumber, String componentName) {
		super(registrationNumber, componentName);
	}


	public void update(Observable thing, Object notificationNumber) {

		Menus menu = new Menus();
		Displays display = new Displays();
		Project myProject = new Project();



		if (registrationNumber.compareTo((Integer) notificationNumber) == 0) {
			addToReceiverList("ListProjectsComponent");
			signalReceivers("ListProjectsComponent");

			// Next we ask them to pick a project
			myProject = menu.pickProject(CommonData.theListOfProjects
					.getListOfProjects());

			if (myProject != null) {
				/*
				 * If the project is valid (exists in the list), then we display
				 * the roles that are assigned to it.
				 */
				display.displayRolesAlltimeAssignedToProject(myProject, CommonData.theListOfResources
						.getListOfResources());
			} else {
				System.out.println("\n\n *** Project not found ***");
			}
		}
		removeFromReceiverList("ListProjectsComponent");
	}

}